import type { TableColumn } from '@/components/core/dynamic-table';
import { Tooltip } from 'ant-design-vue';
import { selectDictLabel } from '@/utils/telchina';
import { reactive } from 'vue';

// 当前页面使用的数据
export const pageDataObj = reactive({
  workOrderTypeDict: [],
  industryTypeDict: [],
  regionDict: [],
  infoSerrcesTypeDict: [],
  responsibleUnitDict: [],
  workOrderStatus: [],
});
export type TableColumnItem = TableColumn;

export const baseColumns: TableColumnItem[] = [
  {
    title: '主单',
    key: 'masterNumber',
    dataIndex: 'masterNumber',
    hideInSearch: true,
    align: 'center',
    width: '40px',
    fixed: 'left',
    customRender: ({ record }) => {
      // return <Radio isGroup={true} name='masterNumber' value={record.workOrderNumber}></Radio>;
       return <input type='radio' name='masterNumber' value={record.workOrderNumber}></input>;
    },
  },
  {
    title: '工单编号',
    key: 'workOrderNumber',
    dataIndex: 'workOrderNumber',
    align: 'center',
    width: '120px',
    fixed: 'left',
    formItemProps: {
      order: 1,
      helpMessage: '可输入一组编号进行查询,如 0712300008,0712310203',
      colProps: {
        span: 4,
      },
    },
  },
  {
    title: '并单状态',
    key: 'consStatus',
    dataIndex: 'consStatus',
    align: 'center',
    fixed: 'left',
    width: '80px',
    formItemProps: {
      label:'主单',
      order: 5,
      component: 'Switch',
      componentProps:{
        checkedValue: '2',
        unCheckedValue: '',
      },
      colProps: {
        span: 2,
      },
    },
    customRender: ({ record }) => {
      return record.consStatus == 0 ? '未并单' : record.consStatus == 1 ? '附单' : '主单';
    },
  },
  {
    title: '并单编号',
    key: 'masterOrderId',
    dataIndex: 'masterOrderId',
    hideInSearch: true,
    align: 'center',
    width: '120px',
    fixed: 'left',
    formItemProps: {
      colProps: {
        span: 6,
      },
    },
  },
  {
    title: '工单状态',
    key: 'workOrderStatus',
    dataIndex: 'workOrderStatus',
    align: 'center',
    width: 120,
    customRender: ({ record }) => {
      return selectDictLabel(pageDataObj.workOrderStatus, record.workOrderStatus);
    },
    hideInSearch: true,
    formItemProps: {
      // colProps:{
      //   span: 6,
      // },
      component: 'Select',
    },
  },

  {
    title: '主题',
    key: 'problemDesc',
    dataIndex: 'problemDesc',
    align: 'center',
    width: 300,
    hideInSearch: true,
    formItemProps: {
      colProps: {
        span: 6,
      },
    },
    customRender: ({ record }) => {
      return (
        <Tooltip title={record.problemDesc}>
          <div class="ellipsis" style={{ float: 'left', maxWidth: '100%' }}>
            {record.problemDesc}
          </div>
        </Tooltip>
      );
    },
  },

  {
    title: '发生地址',
    key: 'occAddress',
    dataIndex: 'occAddress',
    align: 'center',
    width: 300,
    formItemProps: {
      order: 2,
      colProps: {
        span: 6,
      },
    },
    customRender: ({ record }) => {
      return (
        <Tooltip title={record.occAddress}>
          <div class="ellipsis" style={{ float: 'left', maxWidth: '100%' }}>
            {record.occAddress}
          </div>
        </Tooltip>
      );
    },
  },
  {
    title: '行业类型',
    key: 'industryType',
    dataIndex: 'industryType',
    align: 'center',
    hideInTable: true,
    width: 120,
    customRender: ({ record }) => {
      return selectDictLabel(pageDataObj.industryTypeDict, record.industryType);
    },
    formItemProps: {
      order: 3,
      component: 'TreeSelect',
      colProps: {
        span: 6,
      },
    },
  },
  {
    title: '登记时间',
    key: 'acceptTime',
    dataIndex: 'acceptTime',
    align: 'center',
    width: '180px',
    formItemProps: {
      order: 4,
      component: 'RangePicker',
      colProps: {
        span: 6,
      },
      componentProps: {
        showTime: true,
      },
    },
  },
  {
    title: '子单',
    key: 'slaveNumber',
    dataIndex: 'slaveNumber',
    hideInSearch: true,
    align: 'center',
    width: '40px',
    fixed: 'right',
    customRender: ({ record }) => {
      // return <Radio isGroup={true} name='masterNumber' value={record.workOrderNumber}></Radio>;
       return <input type='checkbox' name='slaveNumber' value={record.workOrderNumber}></input>;
    },
  },
];
